<?php

/****************************************************
DESCRIPTION: 	SLIDER OPTIONS
OPTION HANDLE: 	canon_options_slider
****************************************************/


	/****************************************************
	REGISTER MENU
	****************************************************/

	add_action('admin_menu', 'register_canon_options_slider');

	function register_canon_options_slider () {
		global $screen_handle_canon_options_slider;	  	//this is the SCREEN handle used to identify the new admin menu page (notice: different than the add_menu_page handle)

		$screen_handle_canon_options_slider = add_submenu_page(
			'handle_canon_options',					//the handle of the parent options page. 
			'Slider Settings',						//the submenu title that will appear in browser title area.
			'Slider',								//the on screen name of the submenu
			'manage_options',						//privileges check
			'handle_canon_options_slider',			//the handle of this submenu
			'display_options_slider'				//the callback function to display the actual submenu page content.
		);

	}

	/****************************************************
	INITIALIZE MENU
	****************************************************/

	add_action('admin_init', 'init_canon_options_slider');	
	
	function init_canon_options_slider () {
		register_setting(
			'group_canon_options_slider',				//group name. The group for the fields custom_options_group
			'canon_options_slider',						//the options variabel. THIS IS WEHERE YOUR OPTIONS ARE STORED.
			'validate_canon_options_slider'				//optional 3rd param. Callback /function to sanitize and validate
		);

		//if this is first runthrough set default values
		if (get_option('canon_options_slider') == FALSE) {		//trying to get options 'canon_options_slider' which doesn't yet exist results in FALSE
		 	$options = array (

		 			'slides'					=> array(
		 				'0' => array(
		 					'type' 				=> 'image_slide',
		 					'title' 			=> 'My 1st Image Slide',
		 					'text'				=> '<h1>I love scotch</h1> 
<h3>Scotchy, scotch, scotch. Here it goes down, down into my belly...</h3>
<p>This minimal HTML5 theme is designed for showcasing apps, products or basically anything in a full screen slider.</p> 
<p><a class="btn" target="_blank" href="http://themeforest.net/item/kodax-full-screen-landing-page/3634009?ref=KennyWilliams">Download Now</a></p>',
							'text_alignment'	=> 'left',
		 					'post_id' 			=> '2',
		 					'image_url' 		=> get_template_directory_uri() . '/img/1.jpg',
		 					'status' 			=> 'open',
		 				),
		 				'1' => array(
		 					'type' => 'image_slide',
		 					'title' => 'My 2nd Image Slide',
		 					'text' => '<h1>I love scotch</h1> 
<h3>Scotchy, scotch, scotch. Here it goes down, down into my belly...</h3>
<p>This minimal HTML5 theme is designed for showcasing apps, products or basically anything in a full screen slider.</p> 
<p><a class="btn" target="_blank" href="http://themeforest.net/item/kodax-full-screen-landing-page/3634009?ref=KennyWilliams">Download Now</a></p>',
							'text_alignment'	=> 'left',
		 					'post_id' => '2',
		 					'image_url' => get_template_directory_uri() . '/img/2.jpg',
		 					'status' => 'open',
		 				),
		 				'2' => array(
		 					'type' => 'image_slide',
		 					'title' => 'My 3rd Image Slide',
		 					'text' => '<h1>I love scotch</h1> 
<h3>Scotchy, scotch, scotch. Here it goes down, down into my belly...</h3>
<p>This minimal HTML5 theme is designed for showcasing apps, products or basically anything in a full screen slider.</p> 
<p><a class="btn" target="_blank" href="http://themeforest.net/item/kodax-full-screen-landing-page/3634009?ref=KennyWilliams">Download Now</a></p>',
							'text_alignment'	=> 'right',
		 					'post_id' => '2',
		 					'image_url' => get_template_directory_uri() . '/img/3.jpg',
		 					'status' => 'open',
		 				),
		 			),

				);

			update_option('canon_options_slider', $options);
		}
	}



	/****************************************************
	VALIDATE INPUT AND DISPLAY MENU
	****************************************************/

	//remember this will strip all html php tags, strip slashes and convert quotation marks. This is not always what you want (maybe you want a field for HTML?) why you might want to modify this part.	
	function validate_canon_options_slider ($new_instance) {				
		return $new_instance;
	}

	//display the menus
	function display_options_slider () {
		require "options_slider.php";
	}